function [accval, model] = BCCCE (r1, ensemble, truelabel, k, k_hat, MAXCOUNT,flag, str)

% BC3E
% Bayesian Classification and Clustering Ensemble

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%
% Input:
% r1: number of classifier ensemble
% ensemble: output(labels) from classifier an clustering ensemble with first 
% r1 columns specifying classifier ensemble
% truelabel: actual labels of instances
% k: number of classifiers
% k_hat: number of consensus clusters
% MAXCOUNT: Maximum iterations of EM allowed
%%%%%%%%%%%
% Output:
% accval: accuracy of classification
% model: model with all the parameter (variational and model) values
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

format long;
warning('off');

if(nargin<4)
 k        = 2;
 k_hat    = 4;
 MAXCOUNT = 20;
end

MaxFun       = 10;  % Maximum number of function evaluations in calling fmincon or fminunc
MAXESTEPITER = 10;  % maximum E-step iteration
MAXMSTEPITER = 10;  % maximum M-step iteration

data            = dataforBCCCE(r1, ensemble, truelabel, k, k_hat);
[model, accval] = variational_EM(data, MAXCOUNT, MAXESTEPITER, MAXMSTEPITER, MaxFun,flag, str); 


end

